package io.hilo.example.biz01.web.demo;

import org.jretty.apibase.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.hilo.example.biz01.pojo.LoginUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * API测试接口
 */
@RestController
@RequestMapping("/api")
@Api("测试接口")
public class ApiTestController {

    /**
     * 获取用户信息
     */
    @GetMapping("userInfo")
    @ApiOperation(value = "获取用户信息")
    @ApiImplicitParam(paramType = "header", name = "token", value = "token", required = true)
    public Result<?> userInfo(LoginUser user) {
        return Result.success(user);
    }

    /**
     * 忽略Token验证测试
     */
    @GetMapping("notToken")
    @ApiOperation(value = "忽略Token验证测试")
    public Result<?> notToken() {
        return Result.success("无需token也能访问。。。");
    }
    
    @GetMapping("notToken0")
    @ApiOperation(value = "忽略Token验证测试")
    public Result<?> notToken0(
            @ApiParam(value = "手机号", required = true) @RequestParam String mobile,
            @ApiParam(value = "密码", required = true)   @RequestParam String password) {
        
        return Result.success().put("mobile", mobile).put("password", password);
    }
    
}
